<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drag</title>
    <style>
        .box1 {
            width: 200px;
            height: 300px;
            border: 1px solid black;
        }

        .box1 > div {
            width: 48px;
            height: 48px;
            border: 1px solid blue;
            border-radius: 50%;
            background-color: red;
            float: left;
            text-align: center;
            line-height: 48px;
        }

        .box2 {
            width: 200px;
            height: 300px;
            border: 1px solid black;
            position: absolute;
            left: 500px;
            top: 200px;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div draggable="true">1</div>
        <div draggable="true">2</div>
        <div draggable="true">3</div>
        <div draggable="true">4</div>
        <div draggable="true">5</div>
        <div draggable="true">6</div>
        <div draggable="true">7</div>
        <div draggable="true">8</div>
    </div>
    <br/><br/>
    <div class="box2"></div>
    <script>
        var boxs = document.querySelectorAll(".box1 div");

        var box2 = document.querySelector(".box2");

        var temp = null;
        for (var i = 0; i < boxs.length; i++) {
            boxs[i].ondragstart = function() {
                temp = this;
                console.log(temp);
            }

            boxs[i].ondragend = function() {
                console.log(1)
                temp = null;
                console.log(temp);
            }
        }

        // 目标元素的拖拽事件
        box2.ondragover = function(e) {
            e.preventDefault();
        }

        box2.ondrop = function() {
            console.log(2)
            this.appendChild(temp);
        }

    </script>
</body>
</html>